package com.ztom.offer.v2;

/**
 * 替换空格
 * <p>
 * https://leetcode-cn.com/problems/ti-huan-kong-ge-lcof/
 *
 * @author ZhangTao
 */
public class Code03ReplaceSpace {

    public String replaceSpace(String s) {
        if (s == null || s.length() == 0) {
            return "";
        }

        StringBuilder builder = new StringBuilder();
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            if (c == ' ') {
                builder.append("%20");
            } else {
                builder.append(c);
            }
        }
        return builder.toString();
    }
}
